home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93c.txt
/
000119_icon-group-sender _Wed Dec 15 20:12:49 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-02-02
|
2KB
Received: by cheltenham.cs.arizona.edu; Wed, 15 Dec 1993 18:26:48 MST
Date: 15 Dec 93 20:12:49 GMT
From: agate!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!fnnews.fnal.gov!fnalv.fnal.gov!mglass@ucbvax.Berkeley.EDU
Organization: Fermi National Accelerator Lab
Subject: Powersets and every x:=!S insert(S...
Message-Id: <1993Dec15.141249.1@fnalo.fnal.gov>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
May I jump in and combine two recent threads? Specifically,
the recent question about how to compute a powerset intersects
with the long discussion of "every x := !S do insert(S, ...)."
One cool way to compute a powerset, given a set S, is:
ps := set([set()])
every insert(ps, set([!S]) ++ !copy(ps))
This should be, I believe, a fairly convincing example of why
even a rigorous programmer might occasionally write a statement of
the form:
"every x := !ps do insert(ps, ...)"
It was suggested that using copy() will clean up the problem
with such constructions, as it did above. If icon sets behaved
like real sets, the following might work:
* every insert(ps, set([!S]) ++ !ps)
However one can hardly recommend such a practice! Suppose
you were computing for example, the products of all the subsets,
instead of the subsets themselves. Without invoking copy(), the
following might not work:
products := set([1])
every insert(products, !S * !copy(products))
An amusing side-note is the illusion that the "++" set union
operator is not commutative! In my example
!copy(ps) ++ set([!S])
is not the same as
set([!S]) ++ !copy(ps)
It is this apparent non-commutative behavior--really order of
generation and evaluation--which bugged my original construction,
which was to compute the powerset by successively _deleting_ elements:
* ps := set(S)
* every insert(ps, !copy(ps) -- set([!S]))
Enough!
-- Michael Glass | Practice random acts of
mglass@fnalv.fnal.gov | humor and senseless mirth.